package com.example.controller;

import com.example.service.ThreadLocalExampleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/thread/local/example")
public class ThreadLocalExampleController {

    @Autowired
    private ThreadLocalExampleService threadLocalExampleService;

    // 模拟多线程使用ThreadLocal的接口
    @GetMapping("/simulate-threadlocal")
    public String simulateThreadLocalUsage() {
        threadLocalExampleService.simulateThreadLocalUsage();
        return "ThreadLocal 多线程示例任务已启动";
    }
}
